#include "client-handler.hh"

ClientHandler::ClientHandler ()
  : cl_ ()
  , db_ (new Database ("content/playerdata.db"))
{
}

ClientHandler::~ClientHandler ()
{
  // save each client in a conf_file
}

void
ClientHandler::new_client (tcp::socket* sock)
{
  // char* buf = new char[1000];
  // boost::system::error_code error;
  // size_t len = 0;

  // lecture de la requete connexion

  // on construit la string du login et la string du password
  std::string login = "";
  std::string password = "";

  PlayerInfo* player = db_->find_player (login);

  // login valide && password valide
  if (player && player->pass () == password)
    {
      // on reponds good au client
      
      // on l'ajoute dans la liste des clients
    }
  else
    {
      boost::asio::write(*sock, boost::asio::buffer("Bad Login or Password"), ignored_error);
    }
}
